package com.snack.controller;

import com.snack.common.result.Result;
import com.snack.entity.pojo.User;
import com.snack.service.LoginService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.http.HttpRequest;

/**
 * @author huangfuhao
 * @Date 2025/3/13
 */
@RestController
@RequestMapping("/api/login")
public class LoginController {
    @Resource
    private LoginService loginService;


    /**
     * 用户登录
     * @param user
     * @return
     */
    @PostMapping("/login")
    public Result login(@RequestBody User user){
        return loginService.login(user);
    }

    /**
     * 退出登录
     * @param request
     * @return
     */
    @PostMapping("/logout")
    public Result logout(HttpServletRequest request){
        return loginService.logout(request);
    }

}
